package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:看run和thread的区别
 * User: WHY
 * Date: 2022-09-11
 * Time: 14:13
 */
//区别在与run在跑的时后不会创建新的新的线程，就在main线程上跑，但是用start方法就会创建新得线程
class MyThread2  extends    MyThread{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class demo9 {
    public static void main(String[] args) {
        MyThread2 t=new MyThread2();
        t.start();
       // t.run();

        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }

}
